
/*
	This is main program
*/

import java.util.*;
public class Mainclass
{
	 
	public static void main(String args[])
	{
		int choice,i;
		String key="",id;	
		  
		Map<String,Salary> mp1=new HashMap<String,Salary>();
		Scanner scan = new Scanner(System.in);
		List<Salary> EmpList=new ArrayList<Salary>();          //Create the List
		
		SwapnilMap map=new SwapnilMap();                     // create map
		
		
		do
		{
			System.out.print("\n 1.Add Record \n 2.Display All \n 3.Sort on Emp id  \n 4.Search in Map \n 5.Check map empty and size");
			System.out.print("\n 6.Remove the record \n 7.Delete all record from map \n8.Check emp id present or not \n 9.Display All keys\n10.Exit ");
			System.out.print("\n Enter your choice : ");
			choice=scan.nextInt();
			switch(choice)	
			{
				case 1:
										
					Salary obj=new Salary();            //Create the object of Salary Class
					obj.GetEmpData();
					obj.GetCompanyData();
					obj.GetSalaryData();			//get input
					mp1.put(obj.Name+obj.Age,obj);
					EmpList.add(obj);                 	//Add to list
					map.put(""+obj.Empid,obj);
					
					if(obj.equals(obj))
						System.out.print("\nEquals");
					else
						System.out.print("\n not Equals");
					
					break;
				/*case 2:
					

					System.out.print("\n Empid  Name    age    Post   Company     city    Salary   exp   Hashcode\n");
					for(Salary temp:EmpList)
					{
						
						temp.Display(temp.Empid,temp.Name,temp.Age);
						temp.Display(temp.Cname,temp.Post,temp.City);
						temp.Display(temp.salary,temp.workExp);
											     //Display Record
						System.out.print("     "+temp.Hashcode());
						System.out.println();	
						
						
						
					}*/
				case 2: 

					System.out.print("\n Empid  Name    age    Post   Company     city    Salary   exp   Hashcode\n");
					Object[] val=map.values();
					for(i=0;i<map.size();i++)
					{
						Salary temp=(Salary)val[i];
						temp.Display(temp.Empid,temp.Name,temp.Age);
						temp.Display(temp.Cname,temp.Post,temp.City);
						temp.Display(temp.salary,temp.workExp);
											     //Display Record
						System.out.print("     "+temp.Hashcode());
						System.out.println();	
						
						
						
					}


					break;
				case 3:
					
					Collections.sort(EmpList,new IdComparator());
					System.out.print("\n Sorting Has been Completed ");         // Used of comapator and sort the List on Emp id 
					break;	
				case 4:
					System.out.print("\n Enter the Emp id to Search : ");	
					id=scan.next();                                            // Here we send key value and map to object and Display
					Salary arg=(Salary)map.get(id);	
					
					if(arg!=null)
					{
						System.out.print("\n Empid  Name    age    Post   Company     city    Salary   exp  \n");
						arg.Display(arg.Empid,arg.Name,arg.Age);
						arg.Display(arg.Cname,arg.Post,arg.City);
						arg.Display(arg.salary,arg.workExp);	      // Display Record of particular object
						System.out.println();	
					}
					else
						System.out.print("\n Record not Present ");

					break;
					
			      case 5:if(map.isEmpty())
					   	System.out.print("\n Map is empty ");
					else
						System.out.print("\n Map is not empty ");
					System.out.print("\n Size of Map is :"+map.size());
					break;

		 	      case 6:System.out.print("\n Enter the Empid to be deleted ");
					id=scan.next(); 
					map.remove(id);
					System.out.print("\n Record is deleted ");
					break;
			     case 7:map.clear();
					System.out.print("\n All record has been deleted ");
					break;
			     case 8:
					System.out.print("\n Enter the Emp id to Search : ");	
					id=scan.next();  
					if(map.containskey(id))
					System.out.print("\n Key is present ");
				     else
					System.out.print("\n Key is not present ");	
			    case 9:
					System.out.print("\n Keys are ..");
					for(String keyid:map.KeySet())
					  System.out.print("\n "+keyid);
					break;					
					
							
				
			}
		}
		while(choice<10);
		

		
	}
}
